package com.nsgf.library.data.bean;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

import com.google.gson.annotations.SerializedName;
import com.nsgf.library.data.api.APIs;
import com.zhht.htzx.BR;

import java.util.List;

public class OrderListBean {
    /**
     * list : [{"id":0,"no":"","type":0,"status":0,"productCount":0,"commentStatus":false,"createTime":"","payOrderId":0,"payPrice":0,"deliveryType":0,"items":[{"id":0,"orderId":0,"spuId":0,"spuName":"","skuId":0,"properties":[{"propertyId":0,"propertyName":"","valueId":0,"valueName":""}],"picUrl":"","count":0,"commentStatus":false,"price":0,"payPrice":0,"afterSaleId":0,"afterSaleStatus":0}],"combinationRecordId":0}]
     * total : 0
     */

    private int total;
    private List<ListBean> list;

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public List<ListBean> getList() {
        return list;
    }

    public void setList(List<ListBean> list) {
        this.list = list;
    }

    public static class ListBean extends BaseObservable {
        private String id;
        private String no;
        private int type;
        private int status;
        private String statusSrc;
        private int productCount;
        private boolean commentStatus;
        private String createTime;
        private int payOrderId;
        private String payPrice;
        private int deliveryType;
        private int combinationRecordId;
        private List<ItemsBean> items;
        private String tenantName;

        private String refundStatus;
        /**
         * user : {"id":16648,"nickname":"用户昵称6584","avatar":"https://zhonghehuitong.com.cn/zhht/7d0bf64692b8bd319a646957ff9fa2183f556523643d2bb67008e11aad0aa092.jpg","mobile":"15850596584"}
         */

        private UserBean user;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getNo() {
            return no;
        }

        public String getNoSrc() {
            return "订单号：" + getNo();
        }

        public void setNo(String no) {
            this.no = no;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }

        @Bindable
        public int getStatus() {
            return status;
        }

        @Bindable
        public String getStatusSrc() {

            switch (getStatus()) {
                case 0:
                    return "待支付";
                case 10:
                    if (!getItems().isEmpty()) {
                        for (ItemsBean itemsBean : getItems()) {

                            if (itemsBean.getAfterSaleStatus() == 0) {
                                return "待发货";
                            }

                        }
                        switch (getItems().get(0).getAfterSaleStatus()) {
                            case 10:
                                return "退款中";
                            case 20:
                                return "退款成功";
                            default:
                                return "待发货";
                        }
                    }
                    return "待发货";
                case 20:
                    return "已发货";
                case 30:
                    return "已完成";
                case 40:
                    return "已取消";
                default:
                    return "已完成";
            }
        }


        public void setStatus(int status) {
            this.status = status;

            notifyPropertyChanged(BR.status);
        }

        public void setStatusSrc(String statusSrc) {
            this.statusSrc = statusSrc;
            notifyPropertyChanged(BR.statusSrc);
        }

        public int getProductCount() {
            return productCount;
        }

        public void setProductCount(int productCount) {
            this.productCount = productCount;
        }

        public boolean isCommentStatus() {
            return commentStatus;
        }

        public void setCommentStatus(boolean commentStatus) {
            this.commentStatus = commentStatus;
        }

        public String getCreateTime() {
            return createTime;
        }

        public void setCreateTime(String createTime) {
            this.createTime = createTime;
        }

        public int getPayOrderId() {
            return payOrderId;
        }

        public void setPayOrderId(int payOrderId) {
            this.payOrderId = payOrderId;
        }

        public String getPayPrice() {
            return payPrice;
        }

        public void setPayPrice(String payPrice) {
            this.payPrice = payPrice;
        }

        public int getDeliveryType() {
            return deliveryType;
        }

        public void setDeliveryType(int deliveryType) {
            this.deliveryType = deliveryType;
        }

        public int getCombinationRecordId() {
            return combinationRecordId;
        }

        public void setCombinationRecordId(int combinationRecordId) {
            this.combinationRecordId = combinationRecordId;
        }

        public List<ItemsBean> getItems() {
            return items;
        }

        public void setItems(List<ItemsBean> items) {
            this.items = items;
        }

        public String getTenantName() {
            return tenantName;
        }

        public void setTenantName(String tenantName) {
            this.tenantName = tenantName;
        }

        @Bindable
        public String getRefundStatus() {
            return refundStatus;
        }

        public void setRefundStatus(String refundStatus) {
            this.refundStatus = refundStatus;
            notifyPropertyChanged(BR.refundStatus);
        }

        public UserBean getUser() {
            return user;
        }

        public void setUser(UserBean user) {
            this.user = user;
        }


        public String getOrderStatus() {
            for (ItemsBean itemsBean : getItems()) {
                if (itemsBean.getAfterSaleStatus() == 20) {
                    return "退款成功";
                } else if (itemsBean.getAfterSaleStatus() == 10) {
                    return "退款中";
                }
            }
            return getStatusSrc();
        }

        public static class ItemsBean extends BaseObservable {
            /**
             * id : 0
             * orderId : 0
             * spuId : 0
             * spuName :
             * skuId : 0
             * properties : [{"propertyId":0,"propertyName":"","valueId":0,"valueName":""}]
             * picUrl :
             * count : 0
             * commentStatus : false
             * price : 0
             * payPrice : 0
             * afterSaleId : 0
             * afterSaleStatus : 0
             */

            private int id;
            private int orderId;
            private int spuId;
            private String spuName;
            private int skuId;
            private String picUrl;
            private int count;
            private boolean commentStatus;
            private double price;
            private String payPrice;
            private int afterSaleId;
            private int afterSaleStatus;
            private List<PropertiesBean> properties;


            public int getId() {
                return id;
            }

            public void setId(int id) {
                this.id = id;
            }

            public int getOrderId() {
                return orderId;
            }

            public void setOrderId(int orderId) {
                this.orderId = orderId;
            }

            public int getSpuId() {
                return spuId;
            }

            public void setSpuId(int spuId) {
                this.spuId = spuId;
            }

            public String getSpuName() {
                return spuName;
            }

            public void setSpuName(String spuName) {
                this.spuName = spuName;
            }

            public int getSkuId() {
                return skuId;
            }

            public void setSkuId(int skuId) {
                this.skuId = skuId;
            }

            public String getPicUrl() {
                return picUrl;
            }

            public void setPicUrl(String picUrl) {
                this.picUrl = picUrl;
            }

            public int getCount() {
                return count;
            }

            public String getCountSrc() {
                return "x" + count;
            }

            public String getCountBusinessSrc() {
                return "共" + count + "件";
            }

            public void setCount(int count) {
                this.count = count;
            }

            public boolean isCommentStatus() {
                return commentStatus;
            }

            public void setCommentStatus(boolean commentStatus) {
                this.commentStatus = commentStatus;
            }

            public double getPrice() {
                return price;
            }

            public String getPriceSrc() {
                return "¥" + APIs.df.format(price / 100);
            }

            public void setPrice(double price) {
                this.price = price;
            }

            public String getPayPrice() {
                return payPrice;
            }

            public void setPayPrice(String payPrice) {
                this.payPrice = payPrice;
            }

            public int getAfterSaleId() {
                return afterSaleId;
            }

            public void setAfterSaleId(int afterSaleId) {
                this.afterSaleId = afterSaleId;
            }

            @Bindable
            public int getAfterSaleStatus() {
                return afterSaleStatus;
            }

            public void setAfterSaleStatus(int afterSaleStatus) {
                this.afterSaleStatus = afterSaleStatus;
                notifyPropertyChanged(BR.afterSaleStatus);
            }

            public String getAfterSaleStatusSrc() {

                switch (getAfterSaleStatus()) {
                    case 10:
                        return "退款中";
                    case 20:
                        return "退款成功";
                    default:
                        return "";
                }
            }

            public List<PropertiesBean> getProperties() {
                return properties;
            }

            public String getPropertiesSrc() {
                String properties = "";
                for (PropertiesBean bean : getProperties()) {

                    properties += bean.propertyName + ":" + bean.getValueName() + " ";

                }
                return "规格:" + properties;
            }

            public void setProperties(List<PropertiesBean> properties) {
                this.properties = properties;
            }

            public static class PropertiesBean {
                /**
                 * propertyId : 0
                 * propertyName :
                 * valueId : 0
                 * valueName :
                 */

                private int propertyId;
                private String propertyName;
                private int valueId;
                private String valueName;

                public int getPropertyId() {
                    return propertyId;
                }

                public void setPropertyId(int propertyId) {
                    this.propertyId = propertyId;
                }

                public String getPropertyName() {
                    return propertyName;
                }

                public void setPropertyName(String propertyName) {
                    this.propertyName = propertyName;
                }

                public int getValueId() {
                    return valueId;
                }

                public void setValueId(int valueId) {
                    this.valueId = valueId;
                }

                public String getValueName() {
                    return valueName;
                }

                public void setValueName(String valueName) {
                    this.valueName = valueName;
                }
            }
        }

        public static class UserBean {
            /**
             * id : 16648
             * nickname : 用户昵称6584
             * avatar : https://zhonghehuitong.com.cn/zhht/7d0bf64692b8bd319a646957ff9fa2183f556523643d2bb67008e11aad0aa092.jpg
             * mobile : 15850596584
             */

            @SerializedName("id")
            private int idX;
            private String nickname;
            private String avatar;
            private String mobile;

            public int getIdX() {
                return idX;
            }

            public void setIdX(int idX) {
                this.idX = idX;
            }

            public String getNickname() {
                return nickname;
            }

            public String getNicknameSrc() {
                return "订购人：" + nickname;
            }

            public void setNickname(String nickname) {
                this.nickname = nickname;
            }

            public String getAvatar() {
                return avatar;
            }

            public void setAvatar(String avatar) {
                this.avatar = avatar;
            }

            public String getMobile() {
                return mobile;
            }

            public void setMobile(String mobile) {
                this.mobile = mobile;
            }
        }
    }
}
